package com.xmkj.bearuser.my.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.common.Entity.AddressEntity;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/5/10
 * 描述：
 */

public class AdressAdapter extends CommonAdapter<AddressEntity.ListsBean> {
    public AdressAdapter(Context context, List<AddressEntity.ListsBean> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, AddressEntity.ListsBean item, int position) {
        holder.setOnClickListener(R.id.iv_delete, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.iv_compile, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.tv_compile, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.tv_delete, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.iv_setdefault, new OnItemChildClickListener());
        holder.setText(R.id.tv_name, item.username);
        holder.setText(R.id.tv_phone, item.mobile);
        holder.setText(R.id.tv_address, item.address);
        ImageView ivDefault = holder.getView(R.id.iv_setdefault);
        if (item.isdefault == 1) {
            ivDefault.setBackgroundResource(R.mipmap.choose);
        }else {
            ivDefault.setBackgroundResource(R.drawable.choose_enable);
        }

    }

    @Override
    protected int getItemViewLayoutId(int position, AddressEntity.ListsBean item) {
        return R.layout.item_address;
    }
}
